<template>
  <div class="video-all" @click="change">
    <iframe
      height="200"
      width="345"
      :src="showvideo?videoSrc:''"
      frameborder="0"
      allowfullscreen="true"
      v-show="showvideo"
    ></iframe>
    <!-- ?rel=0&amp&autoplay=1 让视频自动播放-->
    <div class="videoCont" v-show="showImg" :style="{'background':'url('+comObj.setvideo.imgUrl+')'}">
      <img src="../../../assets/config_images/PlayButton.png" alt class="img" />
    </div>
  </div>
</template>

<script>
export default {
  props: ["comObj", "nowComIdx"],
  data() {
    return {
      showvideo: false,
      showImg: true
    };
  },
  methods: {
    change() {
      this.showvideo = true;
      this.showImg = false;
    }
  },
  computed: {
    videoSrc: function() {
      return this.comObj.setvideo.videoUrl + "?rel=0&amp&autoplay=1";
    }
  }
};
</script>

<style lang="scss" scoped>
.video-all {
  width: 100%;
  height: 224px;
  padding: 14px 15px;
  .videoCont {
    position: relative;
    width: 100%;
    height: 100%;
    background-image: url(../../../assets/config_images/bg.png);
    background-repeat: no-repeat;
    background-size: cover;
    .img {
      position: absolute;
      top: 0;
      left: 0;
      bottom: 0;
      right: 0;
      margin: auto;
    }
  }
}
</style>
